package com.frost.blog.config;

import com.frost.blog.model.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 统一异常处理
 */
@Slf4j
@ResponseBody
@ControllerAdvice
public class ErrorHandler {
    @ExceptionHandler
    public Result handler(NullPointerException e) {
        log.info(e.toString());
        return Result.fail(e.getMessage());
    }

//    @ExceptionHandler(NullPointerException.class)
//    public Result handler(Exception e) {
//        log.info(e.toString());
//        return Result.fail(e.getMessage());
//    }
}
